---
title: 'Letta'
description: 'Learn how to use the Letta AI SDK provider for the AI SDK.'
---

# Letta Provider

<Note type="warning">
  This community provider is not yet compatible with AI SDK 5. Please wait for
  the provider to be updated or consider using an [AI SDK 5 compatible
  provider](/providers/ai-sdk-providers).
</Note>

The [Letta AI-SDK provider](https://github.com/letta-ai/vercel-ai-sdk-provider) is the official provider for the [Letta](https://docs.letta.com) platform. It allows you to integrate Letta's AI capabilities into your applications using the Vercel AI SDK.

## Setup

The Letta provider is available in the `@letta-ai/vercel-ai-sdk-provider` module. You can install it with:

<Tabs items={['pnpm', 'npm', 'yarn', 'bun']}>
  <Tab>
    <Snippet text="pnpm add @letta-ai/vercel-ai-sdk-provider" dark />
  </Tab>
  <Tab>
    <Snippet text="npm install @letta-ai/vercel-ai-sdk-provider" dark />
  </Tab>
  <Tab>
    <Snippet text="yarn add @letta-ai/vercel-ai-sdk-provider" dark />
  </Tab>
  <Tab>
    <Snippet text="bun add @letta-ai/vercel-ai-sdk-provider" dark />
  </Tab>
</Tabs>

## Provider Instance

You can import the default provider instance `letta` from `@letta-ai/vercel-ai-sdk-provider`:

```ts
import { letta } from '@letta-ai/vercel-ai-sdk-provider';
```

## Quick Start

### Using Letta Cloud (https://api.letta.com)

Create a file called `.env.local` and add your [API Key](https://app.letta.com/api-keys)

```text
LETTA_API_KEY=<your_api_key>
```

```ts
import { lettaCloud } from '@letta-ai/vercel-ai-sdk-provider';
import { generateText } from 'ai';

const { text } = await generateText({
  model: lettaCloud('your_agent_id'),
  prompt: 'Write a vegetarian lasagna recipe for 4 people.',
});
```

### Local instances (http://localhost:8283)

```ts
import { lettaLocal } from '@letta-ai/vercel-ai-sdk-provider';
import { generateText } from 'ai';

const { text } = await generateText({
  model: lettaLocal('your_agent_id'),
  prompt: 'Write a vegetarian lasagna recipe for 4 people.',
});
```

### Custom setups

```ts
import { createLetta } from '@letta-ai/vercel-ai-sdk-provider';
import { generateText } from 'ai';

const letta = createLetta({
  baseUrl: '<your_base_url>',
  token: '<your_access_token>',
});

const { text } = await generateText({
  model: letta('your_agent_id'),
  prompt: 'Write a vegetarian lasagna recipe for 4 people.',
});
```

### Using other Letta Client Functions

The `vercel-ai-sdk-provider` extends the [@letta-ai/letta-client](https://www.npmjs.com/package/@letta-ai/letta-client), you can access the operations directly by using `lettaCloud.client` or `lettaLocal.client` or your custom generated `letta.client`

```ts
// with Letta Cloud
import { lettaCloud } from '@letta-ai/vercel-ai-sdk-provider';

lettaCloud.client.agents.list();

// with Letta Local
import { lettaLocal } from '@letta-ai/vercel-ai-sdk-provider';

lettaLocal.client.agents.list();
```

### More Information

For more information on the Letta API, please refer to the [Letta API documentation](https://docs.letta.com/api).
